<!-- 找回密码 -->
<template>
  <div class="retrieve-container">
    <div class="from">
      <PackFrom :inputArr="FromArr" :btn="butContent" :Errer="'请完成信息的录入'" @submit="subRetrieve"/>
    </div>
  </div>
</template>

<script setup>
import {ref} from "vue"
import PackFrom from "./PackFrom.vue"
import {retrieve} from "@/api/user.js"
let FromArr = ref([
  {
    title: "学号",
    studentId: "",
    err: [
      {
        required: true,
        msg: "请输入学号"
      },{
        regular: '^\\d{9}$',
        msg: "学号必须是9位(必须是数字)"
      }
    ],
    corresponding: "studentId",
    type:"text"
    
  },
  {
    title: "姓名",
    Nickname: "",
    err: [
      {
        required: true,
        msg: "请输入姓名"
      },{
        regular: '[\u4e00-\u9fa5]{2,16}',
        msg: "姓名不规范",
      }
    ],
    corresponding: "Nickname",
    type:"text"
  },
  {
    title: "新密码",
    newLoginPwd:"",
    err: [
      {
        required: true,
        msg: "请输入密码",
      },
      {
        regular: '^\\S{6,10}$',
        msg: "任意字符6-10位(不能有空格等)",
      },
    ],
    corresponding: "newLoginPwd",
    type:"password"
  }
])
const butContent = "找回";
const emit = defineEmits(["change"])


async function subRetrieve(item){
  const res = await retrieve(item)
  if(res.code === 0){
    ElMessage({
      message: "找回成功",
      type: "success",
    });
    emit("change")
  }
}

</script>

<style scoped lang="less">
@import "@/styles/mixin.less";
.retrieve-container{
  width: 100%;
  height: 100%;
  position: relative;
  .from{
    width: 80%;
    .self-center()
  }
}
</style>